//
//  SRHomeworkPictureCollectionViewCell.m
//  StoryShow
//
//  Created by CyonLeuMBP on 2017/9/19.
//  Copyright © 2017年 qudiandu.cn. All rights reserved.
//

#import "SRHomeworkPictureCollectionViewCell.h"

NSString *const kSRHomeworkPictureCollectionViewCell = @"SRHomeworkPictureCollectionViewCell";

@implementation SRHomeworkPictureCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
        // Initialization code
    
    FZStyleSheet *css = [FZStyleSheet currentStyleSheet];
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
//    self.iconImageView.backgroundColor = [UIColor whiteColor];
    self.iconImageView.clipsToBounds = YES;
    self.iconImageView.layer.cornerRadius = 4;
//    self.iconImageView.layer.borderColor = [UIColor whiteColor].CGColor;
//    self.iconImageView.layer.borderWidth = 0.5;
    
    self.titleLabel.backgroundColor = css.color_5;
    self.titleLabel.textColor = css.color_1;
    self.titleLabel.layer.cornerRadius = 35/2.0;
    self.titleLabel.clipsToBounds = YES;
    
    self.backgroundView = [[UIView alloc] init];
    self.backgroundView.backgroundColor = [UIColor clearColor];//[UIColor colorWithWhite:0 alpha:0.6];
    self.backgroundView.clipsToBounds = YES;
    self.backgroundView.layer.cornerRadius = 4;
    self.backgroundView.layer.borderWidth = 1;
    self.backgroundView.layer.borderColor = [UIColor whiteColor].CGColor;
    
    
    self.selectedBackgroundView = [[UIView alloc] init];
    self.selectedBackgroundView.backgroundColor = [UIColor clearColor];//[UIColor colorWithWhite:0 alpha:0.6];
    self.selectedBackgroundView.clipsToBounds = YES;
    self.selectedBackgroundView.layer.cornerRadius = 4;
    self.selectedBackgroundView.layer.borderWidth = 1;
    self.selectedBackgroundView.layer.borderColor = [UIColor redColor].CGColor;
    
//    [self.contentView addSubview:self.selectedBackgroundView];

//    [self.selectedBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self.iconImageView);
//    }];
    self.selectView.backgroundColor =  [UIColor colorWithWhite:0 alpha:0.6];
    self.selectView.clipsToBounds = YES;
    self.selectView.layer.cornerRadius = 5;
//    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.selectView.hidden = YES;
}


- (void)setSelected:(BOOL)selected {
    [super setSelected:selected];
   // Configure the view for the selected state
    
    if (selected) {
    
    if (self.model && [self.model.key isEqualToString:self.rightAnswer]) {
        self.selectedBackgroundView.layer.borderColor = [UIColor colorWithHex:0x10aa14].CGColor;
        self.titleLabel.backgroundColor = [UIColor colorWithHex:0x10aa14];
        self.titleLabel.textColor = [UIColor whiteColor];
        
    } else {
        UIColor *color = [UIColor colorWithHex:0xec3f15];
        self.selectedBackgroundView.layer.borderColor = color.CGColor;
//        FZStyleSheet *css = [FZStyleSheet currentStyleSheet ];
        self.titleLabel.backgroundColor = color;
        self.titleLabel.textColor = [UIColor whiteColor];
    }
   
    } else {
        FZStyleSheet *css = [FZStyleSheet currentStyleSheet ];
        self.titleLabel.backgroundColor = css.color_5;
        self.titleLabel.textColor = css.color_1;
    }
}
- (void)setHighlighted:(BOOL)highlighted {
    [super setHighlighted:highlighted];

    if (highlighted) {
        
        if (self.model && [self.model.key isEqualToString:self.rightAnswer]) {
            self.selectedBackgroundView.layer.borderColor = [UIColor colorWithHex:0x10aa14].CGColor;
            self.titleLabel.backgroundColor = [UIColor colorWithHex:0x10aa14];
            self.titleLabel.textColor = [UIColor whiteColor];
            
        } else {
            UIColor *color = [UIColor colorWithHex:0xec3f15];
            self.selectedBackgroundView.layer.borderColor = color.CGColor;
                //        FZStyleSheet *css = [FZStyleSheet currentStyleSheet ];
            self.titleLabel.backgroundColor = color;
            self.titleLabel.textColor = [UIColor whiteColor];
        }
        
    } else {
        FZStyleSheet *css = [FZStyleSheet currentStyleSheet ];
        self.titleLabel.backgroundColor = css.color_5;
        self.titleLabel.textColor = css.color_1;
    }
}

- (void)updateCellInfo:(SRHomeworkAnswerModel *)item {
    self.model = item;
    self.titleLabel.text = item.key;
    [self.iconImageView fz_setImageWithDefaultPlaceholderWithURLString:item.pic];
    
//    if ([item.key isEqualToString:@"A"]) {
//        self.titleLabel.backgroundColor = [UIColor colorWithHex:0x10aa14];
//    }
//    else if ([item.key isEqualToString:@"B"]) {
//        self.titleLabel.backgroundColor = [UIColor colorWithHex:0xffb32e];
//    }
//    else if ([item.key isEqualToString:@"C"]) {
//        self.titleLabel.backgroundColor = [UIColor colorWithHex:0xee1515];
//    }
//    else if ([item.key isEqualToString:@"D"]) {
//        self.titleLabel.backgroundColor = [UIColor colorWithHex:0xefe6de];
//    }
    
}
@end
